#!/bin/bash

export BASE_DIR=`pwd`
export JAVA_OPT=" -Xms256m -Xmx256m -Xmn128m "
export APP="xxl-job-admin-2.3.0.jar"
export P_ID=`ps -ef | grep -w ${APP} | grep -v "grep" | awk '{print $2}'`

if [ "$P_ID" == "" ]; then
    echo "===${APP} process not exists or stop success"
else
    kill -9 $P_ID
    sleep 1
    echo "${APP} killed success"
fi

# start
echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/applogs/start.out 2>&1 &
nohup java ${JAVA_OPT} -jar ${APP} >> ${BASE_DIR}/applogs/start.out 2>&1 &
echo "xxlJob is starting，you can check the ${BASE_DIR}/applogs/start.out"
